<div class="action-dialog-model-fixed-body">
	<div class="detailsBox">
		<div class="openBox">
			<h3>
			<i class="jtIco"></i>编辑合作方</h3>
	        <div class="detaiTab">
	        	<form class="action-ajax-form" action="/rpartner/edit" method="post" >
	            <input type="hidden" name="brandId" value="${vo.brandId}">
	            <input type="hidden" name="oldPartnerName" value="${vo.partnerName}">
	             <input type="hidden" name="id" value="${vo.id}">
	            <table width="100%" border="0" cellspacing="0" cellpadding="0">
	            	<tbody>
						<tr>
							<td width="15%" align="right" class="bg">品牌名称:</td>
							<td width="35%">
                                <input type="text" name="partnerName" disabled="disabled" value="${brand.brandName}">
							</td>
						</tr>
	                	<tr>
	                    	<td align="right" class="bg" width="15%">渠道名称<span style="color: red;">*</span></td>
	                      	<td width="35%">
	                      		<input type="text" name="partnerName" value="${vo.partnerName}">
	                      	</td>
                            <td class="bg" align="right" width="15%">渠道共享:</td>
                            <td >
                                <select id="isShare" name="isShare">
                                    <option value="0" <#if vo.isShare=0>selected="selected" </#if>>否</option>
                                    <option value="1" <#if vo.isShare=1>selected="selected" </#if>>是</option>
                                </select>
                            </td>
	                    </tr>
	                    <tr>
	                    	<td align="right" class="bg" width="15%">申报省份<span style="color: red;">*</span></td>
	                      	<td width="35%">
	                      		<select name="orgProvinceId" id="orgProvinceId">
	                        		<option value="">请选择
	                        		<#list ActOrgEntitys as ActOrgEntity>
	                        			<option value="${ActOrgEntity.orgId}_${ActOrgEntity.orgName}" <#if ActOrgEntity.orgId == vo.orgProvinceId>selected="selected" </#if>>${ActOrgEntity.orgName}
	                        		</#list>
	                        	</select>
	                        <td align="right" class="bg" width="15%">经办人<span style="color: red;">*</span></td>
	                        <td>
	                        	<input type="text" name="operator" readonly="readonly" value="${vo.operator}">
	                        	<input type="hidden" name="operatorId"  value="${vo.operatorId}">
	                        </td>
	                    </tr>
	                    <tr>
	                    	<td align="right" class="bg" width="15%">主要负责人<span style="color: red;">*</span></td>
	                      	<td width="35%">
	                      		<input type="text" name="parPersonLiable" value="${vo.parPersonLiable}"></td>
	                     	<td align="right" class="bg" width="15%">成立时间<span style="color: red;">*</span></td>
	                        <td>
	                        	<@date name="parCreateTime"  class="tabInp" value="${vo.parCreateTime}"/>
	                        </td>
	                    </tr>
	                    <tr>
	                    	<td align="right" class="bg" width="15%">销售区域<span style="color: red;">*</span></td>
	                      	<td width="35%">
	                      		<input type="text" name="saleAddress" value="${vo.saleAddress}"></td>
	                        <td align="right" class="bg" width="15%">经营范围<span style="color: red;">*</span></td>
	                        <td><input type="text" name="scopeOfBusiness" value="${vo.scopeOfBusiness}"></td>
	                    </tr>
	                    <tr>
	                    <td align="right" class="bg" width="15%">销售账期</td>
	                      	<td width="35%">
	                      		<input type="text" id="salesAcTerm" name="salesAcTerm" value="${vo.salesAcTerm}" class="inputNum">&nbsp;月</td>
	                        <td align="right" class="bg" width="15%">联系电话<span style="color: red;">*</span></td>
	                        <td><input type="text" id="parMobile" name="parMobile" value="${vo.parMobile}" class="inputNum"></td>
	                    </tr>
	                    <tr>
							<td align="right" class="bg" width="15%">结算方式<span style="color: red;">*</span></td>
	                        <td>
	                      		<@select type="radio" dataSouceType="parCleareForm" class="only" name="cleareForm" value="${vo.cleareForm}"/>
	                      		<input type="text" name="cleareFormDes" value="${vo.cleareFormDes}">
	                        </td>
	                        <td align="right" class="bg" width="15%">销售模式</td>
	                        <td>
	                      		<@select type="radio" value="${vo.salesModel}" class="only" name="salesModel" dataSouceType="parSalesModel"/>
	                      		<input type="text" name="salesModelDes" value="${vo.salesModelDes}">
	                        </td>
	                    </tr>	                    
	                    <tr>
	                 	   <td align="right" class="bg" width="15%">与EA是否有合作</td>
	                      	<td width="35%">
	                      		<@select type="radio" dataSouceType="YW" class="only" name="isPartnership" value="${vo.isPartnership}"/>
	                      	</td>
	                  	  <td align="right" class="bg" width="15%">销售结构<span style="color: red;">*</span></td>
	                      	<td width="35%">
	                      		一级批发商&nbsp;<input type="text" style="width:25px" id="salesPatternOne" name="salesPatternOne" value="${vo.salesPatternOne}" class="inputNum">&nbsp;家,
	                    		二级批发商&nbsp;<input type="text" style="width:25px" id="salesPatternTwo" name="salesPatternTwo" value="${vo.salesPatternTwo}" class="inputNum">&nbsp;家,
	                    		销售终端&nbsp; <input type="text" style="width:25px" id="salesPatternTerminal" name="salesPatternTerminal" value="${vo.salesPatternTerminal}" class="inputNum">&nbsp;家</td>
	                    </tr>	 
	                    <tr>
	                    	<td align="right" class="bg" width="15%">办公地址<span style="color: red;">*</span></td>
	                    	<td colspan="3">
	                    		<select id="select_provinceId" name="parOfficeProvince" value="${vo.parOfficeProvince}" onchange="provinceOnchange()"></select>&nbsp;&nbsp; 
	                    		<select id="select_areaId" name="parOfficeArea" value="${vo.parOfficeArea}" onchange="areaOnchange()"></select>&nbsp;&nbsp; 
	                    		<select id="select_cityId" name="parOfficeCity" value="${vo.parOfficeCity}" ></select>
	                    		<input type="text" name="parOfficeDetail" value="${vo.parOfficeDetail}">
	                    	</td>
	                    </tr>	                          
	                    <tr><td align="left" class="bg" width="15%" colspan="4" >&nbsp;</td></tr> 
	                    <tr>
	                    	<td align="right" class="bg" width="15%">年销售收入<span style="color: red;">*</span></td>
	                    	<td>
	                    		<input type="text" id="salesIncomeYear" name="salesIncomeYear"  value="${vo.salesIncomeYear}"  class="inputNum">&nbsp;万元
	                    	</td>
	             			<td align="right" class="bg" width="15%">年销售毛利率<span style="color: red;">*</span></td>
	                    	<td>
	                    		<input type="text" id="salesIncomeAll" name="salesIncomeAll" value="${vo.salesIncomeAll}"  class="inputNum">&nbsp;%
	                    	</td>
	                    </tr>       	                         

	                    <tr>
	                    	<td align="right" class="bg" width="15%">市场占有率排名</td>
	                    	<td>
	                    		<input type="text" id="marketOrder" name="marketOrder" value="${vo.marketOrder}" class="inputNum">&nbsp;名
	                    	</td>
	             			<td align="right" class="bg" width="15%">与厂家年销售收入的比重</td>
	                    	<td>
	                    		<input type="text" id="salesProportion" name="salesProportion" value="${vo.salesProportion}"  class="inputNum">&nbsp;%
	                    	</td>
	                    </tr>       	                    
	                    <tr>
	                    	<td align="right" class="bg" width="15%">厂家系统内销售排名</td>
	                    	<td colspan="3">
	                    		<input type="text" id="salesOrder" name="salesOrder" value="${vo.salesOrder}"   class="inputNum">&nbsp;名
	                    	</td>
	                    </tr> 
	                    <tr><td align="left" class="bg" width="15%" colspan="4" >&nbsp;</td></tr> 
	                    <tr>
	                    	<td align="right" class="bg" width="15%">贷款对象<span style="color: red;">*</span></td>
	                    	<td colspan="3">
	                      		<@select type="radio" value="${vo.loanObject}" class="only" name="loanObject" dataSouceType="parLoanObject"/>
	                      		<input type="text" name="loanObjectDes" value="${vo.loanObjectDes}">                    	
	                    	</td>
	                    </tr> 	   
	                    <tr>
	                    	<td align="right" class="bg" width="15%">是否签署回购协议<span style="color: red;">*</span></td>
	                    	<td colspan="3">
	                    		<@select type="radio" dataSouceType="YW"  name="isSignAgreement" value="${vo.isSignAgreement}" />
	                      		<textarea name="signAgreementDes" cols="80" rows="5" placeholder="输入内容限2000字" style="vertical-align:middle">${vo.signAgreementDes }</textarea>
	                    	</td>
	                    </tr>
	                    <tr><td align="left" class="bg" width="15%" colspan="4" style="background: #e2e2e2;font-weight: bold;padding-left: 20px;color: #333;font-size: 14px";>准入条件</td></tr>          
	                                        
	                    <tr>
	                    	<td align="right" class="bg" width="15%">该品牌厂家、销售分公司或办事处是否允许怡亚通信贷经理进入其销售管理系统采集相关数据<span style="color: red;">*</span></td>
	                    	<td>
	                    		<@select type="radio" value="${vo.isPurchaseData}" class="only" name="isPurchaseData" dataSouceType="YW"/>
	                    	</td>
	             			<td align="right" class="bg" width="15%">该品牌厂家、销售分公司或办事处是否愿意安排业务经理配合怡亚通信贷经理参与借款客户的调查<span style="color: red;">*</span></td>
	                    	<td>
	                    		<@select type="radio" value="${vo.isLoanInterview}" class="only" name="isLoanInterview" dataSouceType="YW"/>
	                    	</td>
	                    </tr>    	                    
	                    <tr>
	                    	<td align="right" class="bg" width="15%">该品牌厂家、销售分公司或办事处可提供给怡亚通证实客户真实交易的凭证<span style="color: red;">*</span></td>
	                    	<td colspan="3">
	                  	    	<@select type="checkbox" value="${vo.tradeVoucher}" name="tradeVoucher" dataSouceType="parTradeVoucher"/>
	                      		<input type="text" name="tradeVoucherDes" value="${vo.tradeVoucherDes}">                    	
	                    	</td>
	                    </tr> 	                    
	                    
	                    <tr>
	                    	<td align="right" class="bg" width="15%">融资额度</td>
	                    	<td>
	                    		<input type="text" id="financeMoney" name="financeMoney" value="${vo.financeMoney}"  class="inputNum">&nbsp;万元
	                    	</td>
	             			<td align="right" class="bg" width="15%">担保方式<span style="color: red;">*</span></td>
	                    	<td>
	                    		<@select type="radio" value="${vo.guaranteeWay}" name="guaranteeWay" dataSouceType="YW"/>
	                      		<input type="text" name="guaranteeDes" value="${vo.guaranteeDes}">
	                    	</td>
	                    </tr>   	  
	                    <tr>
	                    	<td align="right" class="bg" width="15%">其他说明</td>
	                    	<td colspan="3">
	                    		<textarea name="otherDes" id="otherDes" cols="50" rows="5" >${vo.otherDes}</textarea>
	                    	</td>
	                    </tr>   
	               	</tbody>
	        	</table>
	        	<div class="openBox action-ajax-load" data-url="<@url value='/rpartner/loadfile?parameter=${vo.id}'/>"></div>
	        	<div class=" mtb20 tac" >
					<input type="submit" class="btn_auto_30 btn_blue" value="保 存">
					<#if vo.id??>
						<a href="/rpartner/delete?parameter=${vo.id}" class="action-ajax-btn btn_auto_30 btn_blue">删除</a>
						<a href="/rpartner/startFlow?id=${vo.id}" class="action-ajax-btn btn_auto_30 btn_blue">发起流程</a>
					</#if>
				</div>
	        </form>
	        </div>
        </div>
	</div>
</div>

<script>
	$(".only").bind("click",function(){
		var inputText = $(this).parent().children("input:last-child");
		var tp = $(this).next().attr("type");
		if (tp == "text") {
			inputText.removeAttr("disabled");
		} else {
			inputText.val(null);
		}
	});
	$("#other").bind("click",function(){
		if ($(this).is(':checked')) {
			$(this).next().removeAttr("disabled");
		} else {
			$(this).next().val(null);
		}
	});
	
 	$("form").submit(function(e){
	  return validate();
	});
 	
 	function validate() {
 		var numRe = /^[0-9]*$/;
 		var flRe = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
 		var salesAcTerm = $("#salesAcTerm").val();
 		if (salesAcTerm != null && !numRe.test(salesAcTerm)) {
 			$.actionDialog({
					message : "销售账期格式不正确"
			});
 			return false;
 		}
 		var orgProvinceId = $("#orgProvinceId").val();
 		if (orgProvinceId == null || orgProvinceId == "") {
  			$.actionDialog({
					message : "请填写申报省份"
			});
 			return false;		
 		}
 		var parMobile = $("#parMobile").val();
 		if (parMobile != null && !numRe.test(parMobile)) {
 			$.actionDialog({
					message : "联系电话格式不正确"
			});
 			return false;
 		}
 		var salesPatternOne = $("#salesPatternOne").val();
 		if (salesPatternOne != null && salesPatternOne != "" && !numRe.test(salesPatternOne)) {
   			$.actionDialog({
					message : "一级批发商数量填写格式错误"
			});
 			return false;		
 		}
 		var salesPatternTwo = $("#salesPatternTwo").val();
 		if (salesPatternTwo != null && salesPatternTwo != "" && !numRe.test(salesPatternTwo)) {
   			$.actionDialog({
					message : "二级批发商数量填写格式错误"
			});
 			return false;		
 		}
 		var salesPatternTerminal = $("#salesPatternTerminal").val();
 		if (salesPatternTerminal != null && salesPatternTerminal != "" && !numRe.test(salesPatternTerminal)) {
   			$.actionDialog({
					message : "销售终端数量填写格式错误"
			});
 			return false;		
 		}
 		var salesIncomeYear = $("#salesIncomeYear").val();
 		if (salesIncomeYear != null && salesIncomeYear != "" && !flRe.test(salesIncomeYear)) {
  			$.actionDialog({
					message : "年销售收入填写格式错误"
			});
 			return false;
 		}
 		var salesIncomeAll = $("#salesIncomeAll").val();
  		if (salesIncomeAll != null && salesIncomeAll != "" && !flRe.test(salesIncomeAll)) {
  			$.actionDialog({
					message : "年销售毛利率填写格式错误"
			});
 			return false;
 		}		
 		var marketOrder = $("#marketOrder").val();
 		if (marketOrder != null && marketOrder != "" && !numRe.test(marketOrder)) {
  			$.actionDialog({
					message : "市场占有率排名填写格式错误"
			});			
 			return false;
 		}
 		var salesProportion = $("#salesProportion").val();
   		if (salesProportion != null && salesProportion != "" && !flRe.test(salesProportion)) {
   			$.actionDialog({
					message : "与厂家年销售收入的比重填写格式错误"
			});	
 			return false;	
 		}			
 		var salesOrder = $("#salesOrder").val();
  		if (salesOrder != null && salesOrder != "" && !numRe.test(salesOrder)) {
    		$.actionDialog({
					message : "厂家系统内销售排名填写格式错误"
			});			
 			return false;
 		}		
 		var financeMoney = $("#financeMoney").val();
    	if (financeMoney != null && financeMoney != "" && !flRe.test(financeMoney)) {
     		$.actionDialog({
					message : "融资额度填写格式错误"
			});					
 			return false;	
 		}			
 		return true;
 	}	
	
	
	
	//省市区三级联动
	provinceLoad();
	function provinceLoad(){
		var provinceCode = $("#select_provinceId").attr('value');
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findProvinces",
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					$("#select_provinceId").empty();
					 $("#select_provinceId").append("<option value=''>请选择</option>"); 
					 $("#select_areaId").empty();
					 $("#select_areaId").append("<option value=''>请选择</option>"); 
					 $("#select_cityId").empty();
					 $("#select_cityId").append("<option value=''>请选择</option>");   
					 $.each(result.data,function(key,value){
					 	if(provinceCode == value[0])
						    $("#select_provinceId").append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
							$("#select_provinceId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");     
					 });
					 provinceOnchange(function(){
					 	 areaOnchange();
					 });
				    
		 		}
	 	});
     };
	
	
	function provinceOnchange(callback){
		var provinceCode = $("#select_provinceId").val() || $("#select_provinceId").attr('value');
		var areaCode = $("#select_areaId").val() || $("#select_areaId").attr('value');
		if(!provinceCode){
			 $("#select_areaId").empty();
			 $("#select_areaId").append("<option value=''>请选择</option>"); 
			 $("#select_cityId").empty();
			 $("#select_cityId").append("<option value=''>请选择</option>");   			
			 return true;
		}
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findCityByProvinceCode",
			data:{provinceCode:provinceCode},
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					 $("#select_areaId").empty();
					 $("#select_areaId").append("<option value=''>请选择</option>"); 
					 $("#select_cityId").empty();
					 $("#select_cityId").append("<option value=''>请选择</option>");   
					 $.each(result.data,function(key,value){
					 	if(areaCode == value[0])
						    $("#select_areaId").append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
					 		$("#select_areaId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");   
						 
					 });
					 callback &&　callback();
		 		}
	 	});
     }
	      
	 function areaOnchange(){
		var areaCode = $("#select_areaId").val() || $("#select_areaId").attr('value');
		var cityCode = $("#select_cityId").val() || $("#select_cityId").attr('value');
		if(!areaCode){
			$("#select_cityId").empty();
		    $("#select_cityId").append("<option value=''>请选择</option>");   
			return true;
		}
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findDistrictByCityCode",
			data:{cityCode:areaCode},
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
				 $("#select_cityId").empty();
				 $("#select_cityId").append("<option value=''>请选择</option>");   
				 $.each(result.data,function(key,value){
				 	if(cityCode == value[0])
					    $("#select_cityId").append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
					else
						$("#select_cityId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");   
				 });
			 }
	 	});
	
			
	}
</script>








